package com.wf.javase;

/**
 * @author mpk
 * @since 2024/6/22 15:48:05
 */

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Scanner;
public class Demo {
    public static void main(String[] args) throws IOException {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyMMdd");
        LocalDateTime now = LocalDateTime.now();
        String yyyMMdd = now.format(formatter);
        System.out.println("当前是" + yyyMMdd + "，请输入创建的文件夹天数");
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        BufferedWriter bufferedWriter = null;
        FileWriter fileWriter = null;
        LocalDateTime time = now.plusDays(1);
        for (int j = 0; j < i; j++) {

            LocalDateTime localDateTime = time.plusDays(j);
            String format = localDateTime.format(formatter);
            File file = new File("D:\\date\\" + format);
            file.mkdirs();
            File file1 = new File("D:\\date\\" + format + "\\" + format + ".md");
            fileWriter = new FileWriter(file1);
            bufferedWriter = new BufferedWriter(fileWriter);

            bufferedWriter.write("这是" + format + "的文件夹");
            bufferedWriter.flush();

        }
       if (bufferedWriter != null) {
           bufferedWriter.close();
       }
       if (fileWriter != null) {
           fileWriter.close();
       }
        scanner.close();
        System.out.println("创建成功");

    }
    //快速排序
    public static void quickSort(int[] arr, int left, int right) {
        int l = left;
        int r = right;
        int pivot = arr[left];
        int temp = 0;
        while (l < r) {
            //先看右边，依次往左递减
            while (l < r && arr[r] >= pivot) {
                r--;
            }
            //再看左边，依次往右递增
            while (l < r && arr[l] <= pivot) {
                l++;
            }
            //如果满足条件则交换
            if (l < r) {
                temp = arr[l];
                arr[l] = arr[r];
                arr[r] = temp;
            }
        }
    }


}
